<template>
  <div class="middle" v-if="bannerList?.length > 0 && enBannerList?.length > 0">
    <div class="title">{{ $t("common.pioneer") }}</div>

    <div class="detail">
      <div class="bg">
        <img
          :src="locale === 'zh-cn' ? bannerList[0].image : enBannerList[0].image"
          alt=""
        />
      </div>

      <div
        class="infoBox"
        @click="jumpTo(locale === 'zh-cn' ? bannerList[0].url : enBannerList[0].url)"
      >
        <el-button type="primary" class="btn">{{ $t("common.more") }}</el-button>
      </div>
    </div>
  </div>
</template>
<script setup>
import { reactive, ref, onMounted } from "vue";
import axios from "axios";
import { useI18n } from "vue-i18n";
const I18n = useI18n();
const { locale } = useI18n();
import { useRouter } from "vue-router";
const router = useRouter();
// 跳转页面
const jumpTo = (path) => {
  router.push(path);
};

const bannerList = ref([]);
const getBanner = async () => {
  try {
    const res = await axios.get(`${apiUrl}/pc/get_pengbu_kaituo_image`, {
      headers: {
        "Authori-zation": `Bearer ${getToken()}`,
      },
    });

    if (res.data.status === 200) {
      bannerList.value = res.data.data.list;
    }
  } catch (e) {}
};

const enBannerList = ref([]);
const getEnBanner = async () => {
  try {
    const res = await axios.get(`${apiUrl}/pc/get_en_pengbu_kaituo_image`, {
      headers: {
        "Authori-zation": `Bearer ${getToken()}`,
      },
    });

    if (res.data.status === 200) {
      enBannerList.value = res.data.data.list;
    }
  } catch (e) {}
};

onMounted(() => {
  getBanner();
  getEnBanner();
});
</script>

<style scoped lang="scss">
.middle {
  margin-top: 60px;

  .title {
    font-size: 32px;
    // font-weight: bold;
    text-align: center;
    margin-bottom: 40px;
  }

  .detail {
    width: 100%;
    height: 650px;
    position: relative;
    
    transition: 0.5s all;

    .bg {
      width: 100%;
      height: 100%;
      overflow: hidden;
      transition: 0.5s all;

      img {
        width: 100%;
      }
    }

    &:hover {
      .infoBox {
        opacity: 1;
        visibility: visible;
      }
    }

    .infoBox {
      position: absolute;
      left: 0;
      bottom: 0;
      background-color: #ffffffaf;
      width: 100%;
      height: 100%;
      opacity: 0;
      visibility: hidden;
      transition: 0.5s all;

      .btn {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 140px;
        height: 41px;
      }
    }
  }
}
</style>
